export const basicRoutes: Sys.Route[] = [
  {
    name: "root",
    path: "/",
    redirect: "/index",
  },
  {
    name: "404",
    path: "/404",
    component: () => import("@/views/error/404.vue"),
  },
  {
    name: "login",
    path: "/login",
    component: () => import("@/views/login/index.vue"),
    meta: {
      title: "登录页",
    },
  },
  {
    name: "test",
    path: "/test",
    component: () => import("@/views/feat/sockjs/index.vue"),
  },
];

export const NOT_FOUND_ROUTE: Sys.Route = {
  name: "not-found",
  path: "/:pathMatch(.*)*",
  redirect: "/404",
};

const getRouteName = (route: Sys.Route) => {
  const names = [route.name];
  if (route.children && route.children.length) {
    names.push(...route.children.flatMap((item) => getRouteName(item)));
  }
  return names;
};
export const basicRoutesName = basicRoutes.flatMap((route) =>
  getRouteName(route)
);

const getRoutePath = (route: Sys.Route) => {
  const paths = [route.path];
  if (route.children && route.children.length) {
    paths.push(...route.children.flatMap((item) => getRoutePath(item)));
  }
  return paths;
};
export const basicRoutesPath = basicRoutes.flatMap((route) =>
  getRoutePath(route)
);
